using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Task;
using DataAccess;

namespace ProjektZespolowy
	{
	public partial class SearchPage : System.Web.UI.Page
		{

		public string GetMiniFoto(string bigFoto)
			{
			if (string.IsNullOrEmpty(bigFoto))
				return "";
			string extension = System.IO.Path.GetExtension(bigFoto);
			bigFoto = bigFoto.Replace(extension, string.Empty);
			return bigFoto + "_mini" + extension;
			}



		public string GetAvatar(user u)
			{

			return u.avatar_mime == null ? "/images/blank-photo.gif" : "/GetUserPicture.aspx?id=" + u.id.ToString();

			}

		protected void Page_Load(object sender, EventArgs e)
			{
			
			SearchTask st = new SearchTask();

			if (Request.QueryString["Phrase"]!= null)
				{
				string phrase = Request.QueryString["Phrase"].ToString();

				if(Request.QueryString["User"]!= null)
					{
					repLastUsers.DataSource = st.SearchUsers(phrase);
					repLastUsers.DataBind();
					}
				
				if(Request.QueryString["Art"]!= null)
					{
					repGaleries.DataSource = st.SearchGaleries(phrase);
					repGaleries.DataBind();
					repLastArt.DataSource = st.SearchArt(phrase);
					repLastArt.DataBind();
					}

				if (Request.QueryString["Tag"] != null)
					{
					repBestArt.DataSource = st.SearchArtsByTag(phrase);
					repBestArt.DataBind();
					}

				if (Request.QueryString["Comment"] != null)
					{
					repActiveForums.DataSource = st.SearchForums(phrase);
					repActiveForums.DataBind();
					repComment.DataSource = st.SearchComments(phrase);
					repComment.DataBind();
					}


				}

			}
		}
	}
